home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-04 | 4.5 KB | 140 lines | [TEXT/EMAC] |
- ;;;
- ;;; Code to install a menu to send events to Think C
- ;;;
-
- (defun tc:do-compile (menu item)
- (let ((err (tc:compile-file (buffer-name))))
- (report-error-in-message-line err)))
-
- (defun tc:do-disassemble (menu item)
- (let ((err (tc:disassemble (buffer-name))))
- (report-error-in-message-line err)))
-
- (defun tc:do-make (menu item)
- (save-some-buffers)
- (let ((err (tc:make)))
- (report-error-in-message-line err)))
-
- (defun tc:do-open-project (menu item)
- (let* ((file (call-interactively (function (lambda (x)
- (interactive "fProject to open: ")
- x))))
- (err (tc:open-project (expand-file-name file))))
- (report-error-in-message-line err)))
-
- (defun tc:do-close-project (menu item)
- (tc:close-project))
-
- (defun tc:do-build-application (menu item)
- (save-some-buffers)
- (let* ((file (call-interactively (function (lambda (x)
- (interactive "FSave application as: ")
- x))))
- (err (tc:build-application (expand-file-name file))))
- (report-error-in-message-line err)))
-
- (defun tc:do-run (menu item)
- (save-some-buffers)
- (let ((err (tc:run)))
- (report-error-in-message-line err)))
-
- (defun tc:do-use-debugger (menu item)
- (setq tc:use-debugger (not tc:use-debugger))
- (CheckItem tc:compile-menu 10 (if tc:use-debugger 1 0)))
-
- (defun tc:do-preprocess (menu item)
- (let ((err (tc:preprocess (buffer-name))))
- (report-error-in-message-line err)))
-
- (defun tc:do-check-syntax (menu item)
- (let ((err (tc:check-syntax (buffer-name))))
- (report-error-in-message-line err)))
-
- (defun find-closing-paren-internal ()
- (let ((out 1)
- (result t))
- (while (not (zerop out))
- (let ((next-find (re-search-forward "[][(){}]" nil t)))
- (if next-find
- (setq out (+ out
- (if (string-match (regexp-quote (char-to-string (preceding-char))) "({[")
- 1 -1)))
- (setq out 0)
- (setq result nil))))
- result))
-
- (defvar latest-find)
-
- (defun find-closing-paren ()
- (let ((start (point))
- (closing-paren (find-closing-paren-internal)))
- (if closing-paren
- (progn
- (setq latest-find (point))
- (blink-matching-open)
- (if (not (= (point) latest-find))
- (goto-char latest-find)))
- (message "Nothing more to balance")
- (goto-char start))))
-
- (defun tc:do-balance (menu item)
- (find-closing-paren))
-
- (defun tc:do-remove-objects (menu item)
- (tc:remove-objects))
-
- (defun tc:do-launch-tpm (menu item)
- (tc:launch-tpm))
-
- (defun tc:do-finf (menu item)
- (tc:send-finf))
-
- (defun tc:do-nmat (menu item)
- (tc:send-nmat))
-
- (defun tc:do-pmat (menu item)
- (tc:send-pmat))
-
- (defun tc:need-tpm-alias-message ()
- (message "Put an alias to the Think Project Manager named “TPM” in the etc folder of Emacs."))
-
- (defun tc:launch-tpm ()
- "Launch Think Project Manager. There should be an alias to the Think Project Manager called TPM in ~/etc."
- (let ((err (launch-application "TPM")))
- (if (= err fnfErr)
- (tc:need-tpm-alias-message)
- (report-error-in-message-line err))))
-
- (defvar tc:have-menus nil)
-
- (if (not tc:have-menus)
- (progn
- (setq tc:edit-menu (NewMenu (get-unique-menu-ID) "Project"))
- (AppendMenu tc:edit-menu "Launch Think Project Manager/0" 'tc:do-launch-tpm)
- (AppendMenu tc:edit-menu "Open Project..." 'tc:do-open-project)
- (AppendMenu tc:edit-menu "Close Project" 'tc:do-close-project)
- (AppendMenu tc:edit-menu "(-" nil)
- (AppendMenu tc:edit-menu "Balance/B" 'tc:do-balance)
- (AppendMenu tc:edit-menu "Find In Next File/T" 'tc:do-finf)
- (AppendMenu tc:edit-menu "(-" nil)
- (AppendMenu tc:edit-menu "Go To Next Error/'" 'tc:do-nmat)
- (AppendMenu tc:edit-menu "Go To Previous Error/`" 'tc:do-pmat)
- (InsertMenu tc:edit-menu 0)
-
- (setq tc:compile-menu (NewMenu (get-unique-menu-ID) "Compile"))
- (AppendMenu tc:compile-menu "Preprocess" 'tc:do-preprocess)
- (AppendMenu tc:compile-menu "Check Syntax/Y" 'tc:do-check-syntax)
- (AppendMenu tc:compile-menu "Disassemble" 'tc:do-disassemble)
- (AppendMenu tc:compile-menu "Compile/K" 'tc:do-compile)
- (AppendMenu tc:compile-menu "(-" nil)
- (AppendMenu tc:compile-menu "Remove Objects" 'tc:do-remove-objects)
- (AppendMenu tc:compile-menu "Make and Use Disk/\\" 'tc:do-make)
- (AppendMenu tc:compile-menu "Build Application..." 'tc:do-build-application)
- (AppendMenu tc:compile-menu "(-" nil)
- (AppendMenu tc:compile-menu "Use Debugger" 'tc:do-use-debugger)
- (AppendMenu tc:compile-menu "Run/R" 'tc:do-run)
- (InsertMenu tc:compile-menu 0)
- (DrawMenuBar)
-
- (setq tc:have-menus t)))
-